<template>
	<view>
		<view class="item1">firstName:{{firstName}}</view>
		<view class="item1">fullName:{{fullName}}</view>
		<view class="item1">count:{{count}}</view>
		<view class="item1">money:{{money}}</view>
		<view class="item1">fullPath:{{fullPath}}</view>
		<button type="primary" @click="myclick">基数按钮</button>
		<button type="primary" @click="addMoney(5)">加钱按钮</button>
		<Test :titel="title"></Test>
	</view>
</template>
<script>
	import Test from '../../components/Test';
	import {
		mapState,
		mapActions,
		mapGetters
	} from 'vuex';
	

	export default {
		components:{
			Test
		},
		computed: {
			// 使用命名空间
			...mapState('example', {
				firstName: state => state.firstName,
				count: state => state.count,
				money: state => state.money,
			}),
			//不使用命名空间
			...mapState({
				fullPath: state => state.example.fullPath
			}),
			//getter方法
			...mapGetters('example', ['fullName'])

		},
		methods: {
			...mapActions('example', [
				'updateCountAsync',
				'addMoney',
			]),
			myclick() {
				console.log(1233)
				this.updateCountAsync({
					num: 5,
					time: 1000
				})
			}
		},
		data(){
			return{
				title:'这是神奇的'
			}
		}
	}
</script>
<style>

</style>
